package com.xucy.springboot.designmodel.structural.composite.composite1;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author xucy
 * @Date 2019-11-04 17:36
 * @Description
 **/

public class CourseCatalog extends CourseComponent {

    List<CourseComponent> list=new ArrayList<>();
    String name;

    CourseCatalog( String name){
        this.name=name;
    }

    @Override
    public void add(CourseComponent courseComponent) {
        list.add(courseComponent);
    }

    @Override
    public String getName() {
       return name;
    }

    @Override
    public void print() {
        System.out.println("目录名："+getName());
        for(int i=0;i<list.size();i++){
            CourseComponent courseComponent=list.get(i);
            courseComponent.print();
        }
    }
}
